package entities.userstate;

import entities.User;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * Trabalho PD - 2014/2015
 * @author a21210380 a21210392
 */
@Entity
@Table(name = "banned_user")
@NamedQueries({
    @NamedQuery(name = "BannedUser.findAll", query = "SELECT b FROM BannedUser b"),
    @NamedQuery(name = "BannedUser.findByIdUser", query = "SELECT b FROM BannedUser b WHERE b.idUser = :idUser"),
    @NamedQuery(name = "BannedUser.findByBanReason", query = "SELECT b FROM BannedUser b WHERE b.banReason = :banReason"),
    @NamedQuery(name = "BannedUser.findByBanDate", query = "SELECT b FROM BannedUser b WHERE b.banDate = :banDate"),
    @NamedQuery(name = "BannedUser.findByExpirationDate", query = "SELECT b FROM BannedUser b WHERE b.expirationDate = :expirationDate")})
public class BannedUser implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idUser")
    private Integer idUser;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "banReason")
    private String banReason;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "banDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date banDate;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "expirationDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expirationDate;
    
    @JoinColumn(name = "idUser", referencedColumnName = "idUser", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private User user;

    public BannedUser() {
    }

    public BannedUser(Integer idUser) {
        this.idUser = idUser;
    }

    public BannedUser(Integer idUser, String banReason, Date banDate, Date expirationDate) {
        this.idUser = idUser;
        this.banReason = banReason;
        this.banDate = banDate;
        this.expirationDate = expirationDate;
    }

    public Integer getIdUser() {
        return idUser;
    }

    public void setIdUser(Integer idUser) {
        this.idUser = idUser;
    }

    public String getBanReason() {
        return banReason;
    }

    public void setBanReason(String banReason) {
        this.banReason = banReason;
    }

    public Date getBanDate() {
        return banDate;
    }

    public void setBanDate(Date banDate) {
        this.banDate = banDate;
    }

    public Date getExpirationDate() {
        return expirationDate;
    }

    public void setExpirationDate(Date expirationDate) {
        this.expirationDate = expirationDate;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUser != null ? idUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BannedUser)) {
            return false;
        }
        BannedUser other = (BannedUser) object;
        if ((this.idUser == null && other.idUser != null) || (this.idUser != null && !this.idUser.equals(other.idUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.extra.BannedUser[ idUser=" + idUser + " ]";
    }

}
